﻿using IntelligentGateway.SmartCommunity.BUS;
using IntelligentGateway.SmartCommunity.DAL;
using IntelligentGateway.SmartCommunity.DevicePlatform;
using IntelligentGateway.SmartCommunity.Model;
using IntelligentGateway.Tools;
using System.Security.Cryptography.X509Certificates;
using System.Text;

namespace IntelligentGateway.SmartCommunity.Server
{
    public class DeviceServer
    {
        public DevInfo dev;
        public static CEMSDeviceSerialData cems_serial = new CEMSDeviceSerialData();
        public static RaspberryPie raspberryPie = new RaspberryPie();
        public DeviceServer()
        {
            cems_serial.OutboundInterval = Convert.ToInt32(AppSettingsHelper.Configuration["OutboundInterval"]);
            cems_serial.HeartCheck = Convert.ToInt32(AppSettingsHelper.Configuration["HeartCheck"]);
            cems_serial.MachineOutbound = Convert.ToInt32(AppSettingsHelper.Configuration["MachineOutbound"]);
            cems_serial.IndoorOutbound = Convert.ToInt32(AppSettingsHelper.Configuration["IndoorOutbound"]);
            cems_serial.CarInOutbound = Convert.ToInt32(AppSettingsHelper.Configuration["CarInOutbound"]);
            cems_serial.MachineAuthorize = Convert.ToInt32(AppSettingsHelper.Configuration["MachineAuthorize"]);
            cems_serial.IndoorAuthorize = Convert.ToInt32(AppSettingsHelper.Configuration["IndoorAuthorize"]);

            int BaudRate = Convert.ToInt32(AppSettingsHelper.Configuration["BaudRate"]);
            int Parity = Convert.ToInt32(AppSettingsHelper.Configuration["Parity"]);
            int dataBits = Convert.ToInt32(AppSettingsHelper.Configuration["DataBits"]);
            int stopBits = Convert.ToInt32(AppSettingsHelper.Configuration["StopBits"]);
            int face_port = Convert.ToInt32(AppSettingsHelper.Configuration["FacePort"]);
            string portname = AppSettingsHelper.Configuration["PortName"];
            //可视对讲
            cems_serial.OpenS0SerialPort(portname, BaudRate, Parity, dataBits, stopBits);
            //人脸识别
            cems_serial.Face_Start(face_port);
            //发送命令队列
            cems_serial.CmdListSend();
            //清零授权点位
            cems_serial.CmdListClear();

        }


    }
}
